<template>
	<uv-popup ref="popup" mode="bottom" bgColor="#F3F4F5" @change="change">
		<view class="flex align-center justify-between padding bg-white margin-bottom">
			<text class="text-green">提示：填充后请注意根据实际情况进行修改</text>
			<text class="cuIcon-close text-green" @click="close"></text>
		</view>
		<view style="overflow-y: auto;height: 50vh;">
			<view class="item-card padding bg-white margin-bottom" v-for="(dataItem, index) in dataArr" :key="index">
				<view>

					<view class="item-top padding-bottom-sm flex align-center justify-between solid-bottom">
						<view class="flex align-center">
							<template>
								<image class="ti-img" :src="`${$hd.baseUrl}/images/farmer/icon-number.png`"
									mode="aspectFit">
								</image>
								<text class="text-gray margin-left-sm">{{dataItem.orderCode}}</text>
							</template>
						</view>

					</view>
					<view class="flex align-center justify-between text-lg margin-tb-sm">
						<view class="flex-sub">
							<view class="w-90 uv-line-1 text-black text-bold">{{dataItem.orderName||''}}</view>
						</view>
						<view class="color-red">
							<text class="text-sm">￥</text>
							<text class="text-bold text-xl">{{dataItem.money}}</text>
						</view>
					</view>
					<view class="text-cut">
						<view class='cu-tag' v-if="dataItem.homeworkType == 1">面积{{dataItem.area}}亩</view>
						<view class='cu-tag' v-else>重量{{dataItem.area}}吨</view>
						<view class='cu-tag' v-if="dataItem.cropAcreUsage">{{ dataItem.cropAcreUsage }}L/亩</view>
					</view>
					<view class="text-gray margin-top-sm flex">
						<view class="flex-sub text-cut">
							地址：{{dataItem.address}}
						</view> <text class="color-blue margin-left">{{dataItem.distance||''}}</text>
					</view>

				</view>
				<view class="flex align-center justify-between margin-top-sm">
					<view class="text-gray">
						推荐作业时间：{{dataItem.dockingPeopleTime||'-'}}
					</view>
				</view>


				<view class="solid-top padding-top-sm margin-top-sm text-right">
					<button class="cu-btn bg-green sm" @click="onSelect(dataItem)">填充订单</button>
					<!-- <button class="cu-btn bg-main sm margin-left-sm" @click="onUpdata">完善照片</button> -->
				</view>
			</view>
			<uv-empty v-if="dataArr.length == 0" mode="history"></uv-empty>
		</view>
	</uv-popup>
</template>
<script>
	export default {
		data() {
			return {
				dataArr: [],
				homeworkType: ''
			}
		},
		mounted() {
			// this.getList()
		},
		methods: {
			open(homeworkType) {
				// if (this.dataArr.length == 0) {
				// 	uni.showToast({
				// 		title: '暂无历史记录',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				this.homeworkType = homeworkType
				this.getList()
				this.$refs.popup.open();
			},
			close() {
				this.$refs.popup.close();
			},
			change(e) {
				console.log('弹窗状态改变：', e);
			},
			onSelect(item) {
				this.$emit('selected', item)
				this.close()
			},
			getList() {
				this.$http.get('cadre/highSeasOrder/getList', {
					params: {
						homeworkType: this.homeworkType
					}
				}).then(res => {
					this.dataArr = res.data.rows
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.item-card {
		border-radius: 20rpx;

		.ti-img {
			width: 40rpx;
			height: 40rpx;
		}

		.jl-text {
			color: #4CA0FF;
		}
	}
</style>